<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-cmn">
<head>
    <meta charset="UTF-8">
    <%@include file="/WEB-INF/jsp/header.jsp"%>
    <link rel="stylesheet" href="${ctx}/statics/js/jquery.form.min.js">
    <style>
        .layui-form-label{
            padding: 0;
            width: 50px;
            text-align: left;
        }
        .xiao{
            height: 30px;
        }
        form input{
            display: inline-block;
            margin-bottom:5px;
        }
        #tupian{
            width: 300px;
            height: 300px;


        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title">医护人员更正</h3>
        </div>
        <div class="panel-body" >
            <div style="">
                <form action="${ctx}/doc/update" id="updateForm" method="post" class="form-inline" style="">
                    <div class="row">
                        <div class="col-md-9" style="width: 60%;">
                            <div class="control-group">
                                <label for="" class="layui-form-label" >
                                    姓名:
                                </label>
                                <input type="hidden" name="woId" value="${medicper.worker.woId}" />
                                <input type="hidden" name="woJubnum" value="${medicper.worker.woJubnum}" />

                                <input type="hidden" name="landCode" value="${medicper.worker.landCode}" />
                                <input type="hidden" name="landPwd" value="${medicper.worker.landPwd}" />
                                <fmt:formatDate value="${medicper.worker.landDate}" var="dd" pattern="yyyy-MM-dd"></fmt:formatDate>
                                <input type="hidden" name="landDate" value="${dd}" />
                                <input type="hidden" name="landState" value="${medicper.worker.landState}" />
                                <input type="text" name="woName" value="${medicper.worker.woName}" class="layui-input" />
                                <span style="color: red;"></span>
                            </div>
                            <div class="control-group">
                                <label for="" class="layui-form-label" >
                                    学历:
                                </label>
                                <input type="text" name="woEducation" value="${medicper.worker.woEducation}"  class="layui-input" />
                                <span style="color: red;"></span>
                            </div>
                            <div class="control-group">
                                <label for="" class="layui-form-label" >
                                    国籍:
                                </label>
                                <input type="text" name="woNationality" value="${medicper.worker.woNationality}"  class="layui-input" />
                                <span style="color: red;"></span>
                            </div>
                            <div class="control-group">
                                <div class="row">
                                    <div class="col-md-4">
                                        <label for="" class="layui-form-label" >
                                            生日:
                                        </label>
                                        <fmt:formatDate value="${medicper.worker.woBirthday}" pattern="yyyy-MM-dd" var="d"/>
                                        <input type="text" name="woBirthday" value="${d}" class="layui-input xiao" />
                                        <span style="color: red;"></span>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="" class="layui-form-label" style="" >
                                            角色:
                                        </label><br/>
                                        <select name="roleId" id="roleId" class="layui-select xiao" style="width: 230px;">
                                            <c:forEach items="${roleList}" var="role">
                                                <option value="${role.roleId}" ${medicper.worker.roleId==role.roleId?"selected":""}>${role.roleName}</option>
                                            </c:forEach>
                                        </select><br/>
                                        <span style="color: red;"></span>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="" class="layui-form-label" >
                                            性别:
                                        </label><br/>
                                        <select name="woSex" id="" class="layui-select xiao" style="width: 230px;">
                                            <option value="0" ${medicper.worker.woSex==0?"selected":""}>男</option>
                                            <option value="1" ${medicper.worker.woSex==1?"selected":""}>女</option>
                                        </select><br/>
                                        <span style="color: red;"></span>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="row">
                                    <div class="col-md-4">
                                        <label for=""  style="width: 60px;" class="layui-form-label" >
                                            婚姻状况:
                                        </label>
                                        <select name="woMaritalstate" id="" class="layui-select xiao" style="width: 230px;">
                                            <option value="0" ${medicper.worker.woMaritalstate==0?"selected":""}>已婚</option>
                                            <option value="1" ${medicper.worker.woMaritalstate==1?"selected":""}>未婚</option>
                                        </select><br/>
                                        <span style="color: red;"></span>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="" class="layui-form-label" style="" >
                                            民族:
                                        </label><br/>
                                        <input type="text" name="woNation" value="${medicper.worker.woNation}" class="layui-input xiao"/>
                                        <span style="color: red;"></span>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="" class="layui-form-label" >
                                            电话:
                                        </label><br/>
                                        <input type="text" name="woPhone" value="${medicper.worker.woPhone}" class="layui-input xiao" />
                                        <span style="color: red"></span>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="row">
                                    <div class="col-md-4">
                                        <label for="" style="width: 60px;" class="layui-form-label" >
                                            工作年限:
                                        </label>
                                        <input type="text" name="workLife" value="${medicper.worker.workLife}" class="layui-input xiao" />
                                        <span style="color: red"></span>
                                    </div>
                                    <div class="col-md-8">
                                        <label for="" style="width: 60px;" class="layui-form-label" >
                                            身份证号:
                                        </label>
                                        <input type="text" name="woIdentityCard" value="${medicper.worker.woIdentityCard}" class="layui-input xiao" />
                                        <span style="color: red"></span>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="control-group">
                                    <label for="" style="width: 60px;" class="layui-form-label" >
                                        现住址:
                                    </label>
                                    <input type="text" name="woAddress" value="${medicper.worker.woAddress}" class="layui-input xiao" />
                                    <span style="color: red"></span>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="row">
                                    <c:if test="${not empty list}" var="flag">
                                        <div class="col-md-4">
                                            <label for="" style="width: 60px;" class="layui-form-label" >
                                                科室:
                                            </label><br/>
                                            <select name="divCode" style="width: 230px;" class="layui-select xiao">
                                                <c:forEach items="${list}" var="di">
                                                    <option value="${di.divCode}" ${medicper.divCode==di.divCode?"selected":""}>${di.divName}</option>
                                                </c:forEach>
                                            </select>
                                        </div>
                                    </c:if>
                                    <c:if test="${not flag}">
                                        <input name="divCode" type="hidden" value="${medicper.divCode}" />
                                    </c:if>
                                    <div class="col-md-8">
                                        <label for="" style="width: 60px;" class="layui-form-label" >
                                            户口住址:
                                        </label>
                                        <input type="hidden" name="createdBy" value="${medicper.worker.createdBy}">
                                        <fmt:formatDate value="${medicper.worker.creationDate}" pattern="yyyy-MM-dd" var="ddd"></fmt:formatDate>
                                        <input type="hidden" name="creationDate" value="${ddd}">
                                        <input type="hidden" name="perId" value="${medicper.perId}" />
                                        <input type="text" name="woResidence" value="${medicper.worker.woResidence}" class="layui-input xiao" />
                                        <span style="color: red"></span>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div id="tupian" style="margin-left: 10px;" class="col-md-4" >
                            <div class="text-center">
                                <img src="${ctx}/res/images/${medicper.worker.woCeavatar}" id="imgPic" class="" style="width: 200px;height: 200px;">
                                <input type="file" name="myfile" id="d" accept="image/png,image/jpeg" style="display: none" />
                                <div style="margin-top: 5px;"><a href="javascript:void(0)"><i class="glyphicon glyphicon-edit" onclick="d.click()">修改</i></a></div>
                                <input name="woCeavatar" value="${medicper.worker.woCeavatar}" type="hidden" id="woCeavatar" />
                            </div>
                            <div style="margin-top: 50px" class="control-group">
                                <label for="" style="width: 60px;" class="layui-form-label" >
                                    个人说明:
                                </label><br/>
                                <textarea name="woPerExplain"rows="10" cols="40"  >${medicper.worker.woPerExplain}</textarea>
                            </div>
                        </div>
                    </div>
                    <div class="text-center" style="padding-top: 5px;">
                        <button type="button" id="updateSubmit" class="btn btn-primary">修改</button>
                        <button type="button" class="btn btn-danger">重置</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<%@include file="/WEB-INF/jsp/footer.jsp"%>
<script type="text/javascript">

    var $inputfile = $("[name=myfile]");
    //获取表单
    var myForm = $("#updateForm");
    $($inputfile).change(function(){
        $(myForm).ajaxSubmit({
            url:ctx+'/doc/uploadPic',
            type:"post",
            dataType:'json',
            success:function(arr){
                $("#imgPic").attr("src",ctx+"/res/images/"+arr);
                $("#woCeavatar").val(arr)
            }
        });

    });



    $(function () {
        $("#updateSubmit").on("click",function () {
            var woName = $("#updateForm [name=woName]").val();//姓名
            var roleId = $("#updateForm [name=roleId]").val();//角色
            var workLife = $("#updateForm [name=workLife]").val();//工作年限
            var woEducation = $("#updateForm [name=woEducation]").val();//学历
            var woNation = $("#updateForm [name=woNation]").val();//民族
            var woIdentityCard = $("#updateForm [name=woIdentityCard]").val();//身份证
            var woBirthday = $("#updateForm [name=woBirthday]").val();//生日
            var woResidence = $("#updateForm [name=woResidence]").val();//户口住址
            var woNationality = $("#updateForm [name=woNationality]").val();//国籍
            var woAddress = $("#updateForm [name=woAddress]").val();//现住址
            var phone = $("#updateForm [name=woPhone]").val();//电话
            var woCeavatar = $("[name=woCeavatar]").val();//证件
            var divCode = $("#updateForm [name=divCode]").val();//科室编号

            if(woName==null || woName==''){
                $("#updateForm [name=woName]").siblings("span").html("姓名不可为空!")
            } else if(woName.length<2){
                $("#updateForm [name=woName]").siblings("span").html("姓名长度不得小于二!")
            } else if(woEducation==null || woEducation==''){
                $("#updateForm [name=woEducation]").siblings("span").html("学历不可以为空!");
            } else if(woNationality==null || woNationality==''){
                $("#updateForm [name=woNationality]").siblings("span").html("国籍不能为空!");
            } else if(woBirthday==null || woBirthday==''){
                $("#updateForm [name=woBirthday]").siblings("span").html("生日不能为空!");
            } else if(woNation==null||woNation==''){
                $("#updateForm [name=woNation]").siblings("span").html("民族不可以为空!");
            } else if(phone.length!=11){
                $("#updateForm [name=woPhone]").siblings("span").html("电话长度为11位!");
            } else if(phone==null || phone==''){
                $("#updateForm [name=woPhone]").siblings("span").html("电话不能为空!");
            }else if(workLife==null || workLife ==''){
                $("#updateForm [name=workLife]").siblings("span").html("请输入工作年限!");
            } else if(woIdentityCard==null || woIdentityCard==''){
                $("#updateForm [name=woIdentityCard]").siblings("span").html("身份证不可以为空!");
            } else if(woIdentityCard.length!=18){
                $("#updateForm [name=woIdentityCard]").siblings("span").html("身份证不正确!");
            } else if(woAddress=null||woAddress==''){
                $("#updateForm [name=woAddress]").siblings("span").html("现住址不能为空!");
            } else if(woResidence==null || woResidence==''){
                $("#updateForm [name=woResidence]").siblings("span").html("户口住址不能为空!");
            }  else if(woCeavatar==null||woCeavatar==''){
                $("#file").html("请选择证件照!")
            } else{
                $("#updateForm").submit();
            }
            //获取焦点
            $("#updateForm input").focus(function () {
                $(this).siblings("span").html("");
            });
            $("#updateForm [name=roleId]").change(function () {
                $(this).siblings("span").html("");
            });
            $("#woPic").change(function () {
                $("#file").html("");
            })

        })
    })
    //搜索日期插件
    $(function () {
        laydate.render({
            elem:'[name=woBirthday]'
        });
    });
</script>
</body>
</html>
